home *** CD-ROM | disk | FTP | other *** search
/ Programming Windows (5th Edition) / Programming Windows, 5th ed. - Companion CD (097-0002183)(1999).iso / Chap18 / Emf13 / Emf13.c next >
Encoding:
C/C++ Source or Header  |  1998-10-09  |  1.2 KB  |  48 lines

  1. /*---------------------------------------
  2.    EMF13.C -- Enhanced Metafile Demo #13
  3.               (c) Charles Petzold, 1998
  4.   ---------------------------------------*/
  5.  
  6. #include <windows.h>
  7.  
  8. TCHAR szClass [] = TEXT ("EMF13") ;
  9. TCHAR szTitle [] = TEXT ("EMF13: Enhanced Metafile Demo #13") ;
  10.  
  11. void CreateRoutine (HWND hwnd)
  12. {
  13. }
  14.  
  15. void PaintRoutine (HWND hwnd, HDC hdc, int cxArea, int cyArea)
  16. {
  17.      ENHMETAHEADER emh ;
  18.      HENHMETAFILE  hemf ;
  19.      POINT         pt ;
  20.      int           cxImage, cyImage ;
  21.      RECT          rect ;
  22.      
  23.      SetMapMode (hdc, MM_HIMETRIC) ;
  24.      
  25.      SetViewportOrgEx (hdc, 0, cyArea, NULL) ;
  26.      
  27.      pt.x = cxArea ;
  28.      pt.y = 0 ;
  29.      
  30.      DPtoLP (hdc, &pt, 1) ;
  31.      
  32.      hemf = GetEnhMetaFile (TEXT ("..\\emf11\\emf11.emf")) ;
  33.      
  34.      GetEnhMetaFileHeader (hemf, sizeof (emh), &emh) ;
  35.      
  36.      cxImage = emh.rclFrame.right - emh.rclFrame.left ;
  37.      cyImage = emh.rclFrame.bottom - emh.rclFrame.top ;
  38.      
  39.      rect.left   = (pt.x - cxImage) / 2 ;
  40.      rect.top    = (pt.y + cyImage) / 2 ;
  41.      rect.right  = (pt.x + cxImage) / 2 ;
  42.      rect.bottom = (pt.y - cyImage) / 2 ;
  43.      
  44.      PlayEnhMetaFile (hdc, hemf, &rect) ;
  45.      
  46.      DeleteEnhMetaFile (hemf) ;
  47. }
  48.